package com.ego.controller;

import com.ego.commons.pojo.EgoResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PageController {
    /**
     * 进入登录页面
     * @return
     */
    @RequestMapping("/")
    public String login(){
        System.out.println("进入登录控制器");
        return "login";
    }

    /**
     * 显示主页面
     * @return
     */
    @RequestMapping("/main")
    public String show(){
        return "index";
    }

    /**
     * 登录成功后跳转的控制器
     */
    @RequestMapping("/loginSuccess")
    @ResponseBody
    public EgoResult loginSuccess(){
        return EgoResult.ok();
    }

    /**
     * 利用restful风格，url中使用{path}进行特殊站位，参数需添加@PathVariable
     */
    @RequestMapping("/{path}")
    public String showPage(@PathVariable String path){
        return path;
    }

    @RequestMapping("/rest/page/item-edit")
    public String showPage(){
        return "item-edit";
    }

}
